package com.cn.zmc.design.factory;

public class SimpleFactory {


    public static void main(String[] args) {
        Factory.getInstance(1).invoke();
    }




    public static interface MethodInterface {

        void invoke();
    }

    public static class MethodA implements MethodInterface {

        @Override
        public void invoke() {
            System.out.println("MethodA");
        }
    }

    public static class MethodB implements MethodInterface {

        @Override
        public void invoke() {
            System.out.println("MethodB");
        }
    }

    public static class MethodC implements MethodInterface {

        @Override
        public void invoke() {
            System.out.println("MethodC");
        }
    }

    public static class Factory {

        public static MethodInterface getInstance (int type) {
            if (type == 1) {
                return new MethodA();
            } else if (type == 2) {
                return new MethodB();
            } else {
                return new MethodC();
            }
        }
    }
}
